#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef pair < int , int > pii;
typedef vector < int > vec;
typedef vector < pii > veg;
typedef long long ll;
typedef double db;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch =='-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int a[N],b[N],cnt,n;

int upd(int x) { return x + (x >> 31 & mod); }

struct BIT {
    int tr[N];
    void reset() { memset(tr,0,sizeof tr); }
    void add(int x,int v) { for(;x <= cnt;x += x & -x) tr[x] += v; }
    int qry(int x,int v = 0) { for(;x;x -= x & -x) v += tr[x]; return v; } 
} T;

int rt[N],ind[N],pre[N],suf[N],cc[N],ans;
vec G[N];

namespace seg {
    const int N = 4e5 + 10;
    int p1[N],p2[N],s1[N],s2[N],ans[N],ch[N][2],sum[N],ndn;
    void pu(int x) {
	sum[x] = upd(sum[ch[x][0]] + sum[ch[x][1]] - mod);
	
	ans[x] = upd(ans[ch[x][0]] + ans[ch[x][1]] - mod);
	ans[x] = upd(ans[x] + 1ll * p1[ch[x][0]] * s2[ch[x][1]] % mod - mod);
	ans[x] = upd(ans[x] + 1ll * p2[ch[x][0]] * s1[ch[x][1]] % mod - mod);
	
	p1[x] = upd(p1[ch[x][0]] + p1[ch[x][1]] - mod);
	p2[x] = upd(p2[ch[x][0]] + p2[ch[x][1]] - mod);
	p2[x] = upd(p2[x] + 1ll * p1[ch[x][0]] * sum[ch[x][1]] % mod - mod);
	
	s1[x] = upd(s1[ch[x][0]] + s1[ch[x][1]] - mod);
	s2[x] = upd(s2[ch[x][0]] + s2[ch[x][1]] - mod);
	s2[x] = upd(s2[x] + 1ll * s1[ch[x][1]] * sum[ch[x][0]] % mod - mod);
    }
    
    void update(int &x,int pos,int val,int s,int p,int l,int r) {
	if(!x) x = ++ndn; if(l == r) return sum[x] = val,s1[x] = s,p1[x] = p,void(); int mid = l + r >> 1;
	if(pos <= mid) update(ch[x][0],pos,val,s,p,l,mid); else update(ch[x][1],pos,val,s,p,mid + 1,r); pu(x);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in; for(int i = 1;i <= n;i++) a[i] = in,b[++cnt] = a[i]; sort(b + 1,b + cnt + 1); cnt = unique(b + 1,b + cnt + 1) - b - 1;
    for(int i = 1;i <= n;i++) a[i] = lower_bound(b + 1,b + cnt + 1,a[i]) - b,ind[i] = ++cc[a[i]],G[a[i]].pb(i);
    for(int i = 1;i <= n;i++) pre[i] = T.qry(a[i]),T.add(a[i],1);
    T.reset();
    for(int i = n;i >= 1;i--) suf[i] = T.qry(a[i]),T.add(a[i],1);
    for(int i = 1;i <= cnt;i++) {
	if(cc[i] <= 2) continue;
	for(auto x : G[i]) seg :: update(rt[i],ind[x],1,suf[x],pre[x],1,cc[i]); ans = upd(ans + seg :: ans[rt[i]] - mod);
    }
    int Q = in;
    while(Q--) {
	int op = in,pos = in;
	if(cc[a[pos]] <= 2) { printf("%d\n",ans); continue; }
	if(op == 1) {
	    int lans = seg :: ans[rt[a[pos]]];
	    seg :: update(rt[a[pos]],ind[pos],0,0,0,1,cc[a[pos]]);
	    ans = upd(ans + seg :: ans[rt[a[pos]]] - mod);
	    ans = upd(ans - lans);
	} else {
	    int lans = seg :: ans[rt[a[pos]]];
	    seg :: update(rt[a[pos]],ind[pos],1,suf[pos],pre[pos],1,cc[a[pos]]);
	    ans = upd(ans + seg :: ans[rt[a[pos]]] - mod);
	    ans = upd(ans - lans);
	}
	printf("%d\n",ans);
    } return 0;
}
